package com.iflytek.hive.need5;


import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class QuatTop10Reducer extends Reducer<QuatOrderBean, LongWritable, QuatOrderBean, IntWritable> {
    private final  IntWritable outKey = new IntWritable();
    @Override
    protected void reduce(QuatOrderBean key, Iterable<LongWritable> values, Context context)throws IOException, InterruptedException {
        int num = 1;
        for (LongWritable i:values) {
            outKey.set(num);
            context.write(key, outKey);
            num++;

            if (num > 10) {
                break;
            }
        }
    }
}
